<template>
  <div class="wrap">
    <div class="topInfo">
      <div class="title">
        <div class="left">
          <img src="../assets/user2.png" alt />
          <p>{{info.username}}</p>
        </div>
        <span class="state">商家已发货</span>
      </div>
      <div class="item" v-for="(item,idx) in list.orderList" :key="idx">
        <div class="item-left">
          <img :src="item.order_image" @click="showMaxImg(item.order_image)" :onerror="defaultImg2" class="avi" alt />
          <div class="productInfo">
            <p>码数：{{item.order_size}}</p>
            <p>价格：￥{{item.supplier_price}}</p>
            <p>
              报货日期：
              <span style="color:#FF536B;">{{item.create_time.split(" ")[0]}}</span>
            </p>
          </div>
        </div>
        <p class="celce" v-if="!state" @click="setproxy(item)">取消代发</p>
      </div>
     
      <div class="bcio">共计{{ list.orderList.length}}件商品  <p class="celce" v-if="!state" @click="all">全部取消</p></div>
      <p class="ydh">运单号：{{list.waybill}}</p>
      <div class="address">
        <div class="tg">
          <img src="../assets/mins.png" alt />
          <div>
            <p>{{list.takeAddress.name}}：{{list.takeAddress.tel}}</p>
            <span>
              {{list.takeAddress.province}}-{{list.takeAddress.city}}-{{list.takeAddress.district}}
              {{list.takeAddress.content}}
            </span>
            <i v-if="!state" @click="editAddress(0)">修改</i>
          </div>
        </div>
        <img src="../assets/zh.png" class="zh" alt />
        <div class="tg">
          <img src="../assets/minj.png" alt />
          <div>
            <p>{{list.deliveryAddress.name}}：{{list.deliveryAddress.tel}}</p>
            <span>
              {{list.deliveryAddress.province}}-{{list.deliveryAddress.city}}-{{list.deliveryAddress.district}}
              {{list.deliveryAddress.content}}
            </span>
             <i v-if="!state" @click="editAddress(1)">修改</i>
          </div>
        </div>
      </div>
    </div>
    <div class="addInfo" v-if="state">
      <div class="utit">
        <img src="../assets/wl.png" alt />
        <p>物流跟踪</p>
      </div>
      <div class="infotext">
        <div>
          <p>运单号：65644651516848949</p>
          <span>复制</span>
        </div>
        <div>
          <p>国内承运人：65644651516848949</p>
        </div>
        <div>
          <p>国内承运人电话：</p>
          <i>65644651516848949</i>
        </div>
      </div>
      <div class="line">
        <ul>
          <li>
            <img src class="rad" alt />
            <div>
              <div class="topi">
                <h3>派送中</h3>
                <span>2020-02-27 18:58</span>
              </div>
              <p>山西省-临汾市-浮山县新风北街分部 派件员 小明山西省-临汾市-浮山县新风北街分部 派件员 小明</p>
            </div>
          </li>
          <li>
            <img src class="rad" alt />
            <div>
              <div class="topi">
                <h3>派送中</h3>
                <span>2020-02-27 18:58</span>
              </div>
              <p>山西省-临汾市-浮山县新风北街分部 派件员 小明山西省-临汾市-浮山县新风北街分部 派件员 小明</p>
            </div>
          </li>
          <li>
            <img src class="rad" alt />
            <div>
              <div class="topi">
                <h3>派送中</h3>
                <span>2020-02-27 18:58</span>
              </div>
              <p>山西省-临汾市-浮山县新风北街分部 派件员 小明山西省-临汾市-浮山县新风北街分部 派件员 小明</p>
            </div>
          </li>
        </ul>
      </div>
    </div>
    <div class="addInfo" v-if="!state">
      <div class="utit">
        <img src="../assets/wl.png" alt />
        <p>物流跟踪</p>
      </div>
      <p class="null">暂无物流信息</p>
    </div>
     <van-popup v-model="maxImgShow">
      <img :src="maxImg" class="maxImg" :onerror="defaultImg2" alt />
    </van-popup>
  </div>
</template>
<style lang="scss" scoped>
.maxImg{
  width: 100%;
}
.topInfo {
  width: 8.4rem;
  border: 1px solid #e5e5e5;
  border-radius: 0.266667rem;
  margin: 0 auto;
  padding: 0.4rem 0.4rem;
  margin-top: 0.4rem;
  .title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6rem;
    .left {
      display: flex;
      align-items: center;
    }
    .left img {
      width: 0.533333rem;
      height: 0.6rem;
      display: flex;
      margin-right: 0.266667rem;
      object-fit: cover;
    }
    .left p {
      color: #555;
      font-size: 0.4rem;
      font-weight: bold;
    }
    .state {
      color: #3fd9c9;
      font-size: 0.373333rem;
      margin-right: 0.773333rem;
    }
  }
  .item {
    padding-bottom: 10px;
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    .item-left {
      display: flex;
    }
    .avi {
      width: 2rem;
      height: 2rem;
      border-radius: 0.266667rem;
      margin: 0.173333rem 0.306667rem 0 0;
      display: block;
      object-fit: cover;
    }
    .productInfo {
      margin-top: 0.4rem;
      p {
        color: #555;
        font-size: 0.32rem;
        text-align: left;
      }
      p:nth-of-type(2) {
        margin-top: 0.133333rem;
        margin-bottom: 0.186667rem;
      }
    }
    .item-right {
      display: flex;
      .state {
        width: 2.4rem;

        p:nth-of-type(1) {
          color: #ff536b;
          font-size: 0.426667rem;
          text-align: center;
          margin-top: 0.266667rem;
          margin-bottom: 0.56rem;
        }
        p:nth-of-type(2) {
          width: 2.213333rem;
          height: 0.573333rem;
          border-radius: 0.266667rem;
          text-align: center;
          background: #3fd9c9;
          font-size: 0.373333rem;
          line-height: 0.573333rem;
          color: #fff;
        }
      }
      .radio {
        width: 0.453333rem;
        height: 0.453333rem;
        border-radius: 50%;
        display: block;
        background: #3fd9c9;
        margin-right: 0.266667rem;
        margin-top: 0.3rem;
      }
    }
    .celce {
      color: #fff;
      font-size: 0.32rem;
      text-align: center;
      background: #3fd9c9;
      border-radius: 50px;
      padding: 0 12px;
      margin-right: .2rem;
      font-weight: normal;
      height: 0.6rem;
      line-height: 0.6rem;
      margin-top: 0.173333rem
    }
  }
  .bcio {
    height: 1.28rem;
    border-top: 1px solid #e5e5e5;
    border-bottom: 1px solid #e5e5e5;
    font-size: 0.346667rem;
    color: #555;
    text-align: right;
    font-weight: bold;
    line-height: 1.28rem;
    padding-right: 0.4rem;
    width: 8.2rem;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    .celce {
      color: #fff;
      font-size: 0.32rem;
      text-align: center;
      background: #3fd9c9;
      border-radius: 50px;
      padding: 0 12px;
      font-weight: normal;
      height: 0.6rem;
      line-height: 0.6rem;
      margin-left: 15px;
    }
  }
  .ydh {
    color: #999;
    font-size: 0.32rem;
    line-height: 1.28rem;
    text-align: left;
  }
  .address {
    display: flex;
    justify-content: space-between;
    align-items: center;
    .tg {
      width: 3.8rem;
      border: 1px solid #e5e5e5;
      border-radius: 0.266667rem;
      display: flex;
      align-items: center;
      min-height: 1.466667rem;
          padding: 5px 5px 5px 0;
      div {
        width: 3rem;
        p {
          color: #555;
          font-size: 0.24rem;
          text-align: left;
        }
        span {
          color: #999;
          font-size: 0.24rem;
          text-align: left;
          display: block;
        }
        i{
          color: #3fd9c9;
          font-style: normal;
          text-align: left;
          display: block;
        }
      }
      img {
        width: 0.4rem;
        height: 0.4rem;
        display: block;
        border-radius: 50%;
        margin-left: 8px;
        margin-right: 8px;
      }
    }
    .zh {
      display: block;
      width: 0.6rem;
      height: 0.6rem;
    }
  }
}
.addInfo {
  width: 8.4rem;
  border: 1px solid #e5e5e5;
  border-radius: 0.266667rem;
  margin: 0 auto;
  padding: 0.4rem 0.4rem;
  margin-top: 0.4rem;
  margin-bottom: 0.6rem;
  .null {
    color: #999;
    font-size: 12px;
    display: flex;
    align-items: center;
    text-align: center;
    justify-content: center;
    margin: 30px 0;
    &::after {
      content: "";
      display: block;
      height: 1px;
      width: 0.6rem;
      background: #999;
      margin-left: 15px;
    }
    &::before {
      content: "";
      display: block;
      height: 1px;
      width: 0.6rem;
      background: #999;
      margin-right: 15px;
    }
  }
  .utit {
    display: flex;
    align-items: center;
    img {
      width: 0.6rem;
      height: 0.6rem;
      display: block;
      margin-right: 0.2rem;
    }
    p {
      color: #555;
      font-size: 0.4rem;
      font-weight: bold;
    }
  }
  .infotext {
    margin-top: 0.4rem;
    margin-left: 0.4rem;
    div {
      display: flex;
      align-items: center;
      p {
        font-size: 0.32rem;
        color: #999;
        line-height: 0.6rem;
      }
      i {
        font-style: normal;
        color: #73a8dd;
      }
      span {
        display: flex;
        background: #e5e5e5;
        padding: 2px 6px;
        font-size: 0.32rem;
        color: #999;
        margin-left: 0.4rem;
        border-radius: 0.1rem;
      }
    }
  }
  .line {
    margin-left: 0.6rem;
    margin-top: 0.4rem;
    ul {
      li {
        list-style: none;
        border-left: 1px solid #e5e5e5;
        padding-bottom: 0.2rem;
        display: flex;
        position: relative;
        img {
          width: 0.4rem;
          height: 0.4rem;
          display: block;
          border-radius: 50%;
          background: #3fd9c9;
          position: absolute;
          left: -0.2rem;
        }
        div {
          .topi {
            display: flex;
            justify-content: space-between;
            align-items: center;
          }

          h3 {
            color: #999;
            font-style: 0.4rem;
            font-weight: bold;
            margin-left: 0.4rem;
          }
          p {
            color: #999;
            font-size: 0.32rem;
            margin-left: 0.4rem;
            margin-top: 0.2rem;
            text-align: left;
          }
        }
      }
    }
  }
}
</style>
<script>
import {editProxy} from '@/utils/interface'
import { Toast, Dialog } from "vant";

export default {
  data() {
    return {
      state: true,
      info:{},
      list:{},
      defaultImg2: 'this.src="'+ require('../assets/timg.jpg') +'"',
      maxImgShow:false,
      maxImg:""
    };
  },
  created() {
    if (this.$route.query.state) {
      if (this.$route.query.state == 1) {
        this.state = false;
        this.list = JSON.parse(this.$route.query.w_list)
      }else {
        this.list = JSON.parse(this.$route.query.y_list)
      }
      console.log( this.list)
      this.info = JSON.parse(this.$route.query.info)
      
    }
  },
  methods:{
    setproxy(item){
      Dialog.confirm({
        title: "提示",
        message: "是否取消代发"
      }).then(res=>{
        editProxy({orderList:item.order_id}).then(res=>{
            if (res.data.code == 200) {
              Toast.success("取消成功");
              this.$router.go(-1);
            }
        })
      })
    },
    all(){
      let orderList = []
      this.list.orderList.map(item=>{
        orderList.push(item.order_id)
      })
      Dialog.confirm({
        title: "提示",
        message: "是否全部取消代发"
      }).then(res=>{
        editProxy({orderList:orderList.toString()}).then(res=>{
            if (res.data.code == 200) {
              Toast.success("取消成功");
              this.$router.go(-1);
            }
        })
      })
    },
    editAddress(n){
      this.$router.push({path:'s_address',query:{n:n}})
    },
     showMaxImg(s) {
      this.maxImgShow = true;
      this.maxImg = s;
    }
  }
};
</script>